<template>
  <el-form :model="form" label-width="200px">
    <!-- 姓名 -->
    <el-form-item label="姓名">
      <el-input v-model="form.name" placeholder="请输入姓名"></el-input>
    </el-form-item>

    <!-- 性别 -->
    <el-form-item label="性别">
      <el-radio-group v-model="form.gender">
        <el-radio :value="'男'">男</el-radio>
        <el-radio :value="'女'">女</el-radio>
      </el-radio-group>
    </el-form-item>

    <!-- 生日 -->
    <el-form-item label="生日">
      <el-date-picker
          v-model="form.birthday"
          type="date"
          placeholder="选择生日"
          style="width: 100%;"
      ></el-date-picker>
    </el-form-item>

    <!-- 地址 -->
    <el-form-item label="地址">
      <el-input
          type="textarea"
          v-model="form.address"
          placeholder="请输入地址"
          :rows="2"
      ></el-input>
    </el-form-item>

    <!-- 联系电话 -->
    <el-form-item label="联系电话">
      <el-input v-model="form.phone" placeholder="请输入联系电话"></el-input>
    </el-form-item>

    <!-- 邮箱 -->
    <el-form-item label="邮箱">
      <el-input v-model="form.email" placeholder="请输入邮箱"></el-input>
    </el-form-item>

    <!-- 提交按钮 -->
    <el-form-item>
      <el-button type="primary" @click="submitForm">提交</el-button>
      <el-button @click="resetForm">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script setup>
import { reactive } from 'vue';
import { ElMessage } from 'element-plus';

// 定义表单数据
const form = reactive({
  name: '',
  gender: '',
  birthday: '',
  address: '',
  phone: '',
  email: '' // 增加邮箱字段
});

// 提交表单
const submitForm = () => {
  console.log('提交数据:', form);
  ElMessage({
    message: '提交成功',
    type: 'success',
  });
};

// 重置表单
const resetForm = () => {
  form.name = '';
  form.gender = '';
  form.birthday = '';
  form.address = '';
  form.phone = '';
  form.email = ''; // 重置邮箱字段
};
</script>

<style scoped>
/* 可以在这里自定义样式 */
</style>
